package com.orange.example.config;

import com.orange.common.threadpool.factory.SelfDefinedNameThreadFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

/**
 * @Description: 创建一个与日志业务有关的线程池
 */
@Configuration
public class LogThreadPool {
    @Bean("LogThreadPool")
    public ThreadPoolExecutor logThreadPoolTaskExecutor() {
        //创建一个线程池
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(10,20,10,
                TimeUnit.SECONDS,new LinkedBlockingQueue<>(1000),new SelfDefinedNameThreadFactory("日志业务"));
        return threadPoolExecutor;
    }
}
